package product.action;

import java.util.ArrayList;
import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import product.dao.BuildingLockEquipmentDao;
import product.dao.BuildingTalkEquipmentDao;
import product.dao.ControlDiskVideoDao;
import product.dao.VideoMatrixDao;
import product.dao.VideoMonitorDao;
import product.dao.VidiconDao;
import product.dao.YuntaiDao;
import product.model.BuildingLockEquipment;
import product.model.BuildingTalkEquipment;
import product.model.ControlDiskVideo;
import product.model.VideoMatrix;
import product.model.VideoMonitor;
import product.model.Vidicon;
import product.model.Yuntai;

import com.opensymphony.xwork2.ActionSupport;

public class ProductAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Long id;
	
	private BuildingLockEquipment buildingLockEquipment;
	
	private BuildingTalkEquipment buildingTalkEquipment;
	
	private ControlDiskVideo controlDiskVideo;
	
	private VideoMatrix videoMatrix;
	
	private VideoMonitor videoMonitor;
	
	private Vidicon vidicon;
	
	private Yuntai yuntai;
	
	private BuildingLockEquipmentDao buildingLockEquipmentDao;
	
	private BuildingTalkEquipmentDao buildingTalkEquipmentDao;
	
	private ControlDiskVideoDao controlDiskVideoDao;
	
	private VideoMatrixDao videoMatrixDao;
	
	private VideoMonitorDao videoMonitorDao;
	
	private VidiconDao vidiconDao;
	
	private YuntaiDao yuntaiDao;
	
	private List<BuildingLockEquipment> buildingLockEquipmentList = new ArrayList<BuildingLockEquipment>();
	
	private List<BuildingTalkEquipment> buildingTalkEquipmentList = new ArrayList<BuildingTalkEquipment>();
	
	private List<ControlDiskVideo> controlDiskVideoList = new ArrayList<ControlDiskVideo>();
	
	private List<VideoMatrix> videoMatrixList = new ArrayList<VideoMatrix>();
	
	private List<VideoMonitor> videoMonitorList = new ArrayList<VideoMonitor>();
	
	private List<Vidicon> vidiconList = new ArrayList<Vidicon>();
	
	private List<Yuntai> yuntaiList = new ArrayList<Yuntai>();
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public List<BuildingLockEquipment> getBuildingLockEquipmentList() {
		return buildingLockEquipmentList;
	}

	public void setBuildingLockEquipmentList(
			List<BuildingLockEquipment> buildingLockEquipmentList) {
		this.buildingLockEquipmentList = buildingLockEquipmentList;
	}

	public List<BuildingTalkEquipment> getBuildingTalkEquipmentList() {
		return buildingTalkEquipmentList;
	}

	public void setBuildingTalkEquipmentList(
			List<BuildingTalkEquipment> buildingTalkEquipmentList) {
		this.buildingTalkEquipmentList = buildingTalkEquipmentList;
	}

	public List<ControlDiskVideo> getControlDiskVideoList() {
		return controlDiskVideoList;
	}

	public void setControlDiskVideoList(List<ControlDiskVideo> controlDiskVideoList) {
		this.controlDiskVideoList = controlDiskVideoList;
	}

	public List<VideoMatrix> getVideoMatrixList() {
		return videoMatrixList;
	}

	public void setVideoMatrixList(List<VideoMatrix> videoMatrixList) {
		this.videoMatrixList = videoMatrixList;
	}

	public List<VideoMonitor> getVideoMonitorList() {
		return videoMonitorList;
	}

	public void setVideoMonitorList(List<VideoMonitor> videoMonitorList) {
		this.videoMonitorList = videoMonitorList;
	}

	public List<Vidicon> getVidiconList() {
		return vidiconList;
	}

	public void setVidiconList(List<Vidicon> vidiconList) {
		this.vidiconList = vidiconList;
	}

	public List<Yuntai> getYuntaiList() {
		return yuntaiList;
	}

	public void setYuntaiList(List<Yuntai> yuntaiList) {
		this.yuntaiList = yuntaiList;
	}

	public BuildingLockEquipment getBuildingLockEquipment() {
		return buildingLockEquipment;
	}

	public void setBuildingLockEquipment(BuildingLockEquipment buildingLockEquipment) {
		this.buildingLockEquipment = buildingLockEquipment;
	}

	public BuildingTalkEquipment getBuildingTalkEquipment() {
		return buildingTalkEquipment;
	}

	public void setBuildingTalkEquipment(BuildingTalkEquipment buildingTalkEquipment) {
		this.buildingTalkEquipment = buildingTalkEquipment;
	}

	public ControlDiskVideo getControlDiskVideo() {
		return controlDiskVideo;
	}

	public void setControlDiskVideo(ControlDiskVideo controlDiskVideo) {
		this.controlDiskVideo = controlDiskVideo;
	}

	public VideoMatrix getVideoMatrix() {
		return videoMatrix;
	}

	public void setVideoMatrix(VideoMatrix videoMatrix) {
		this.videoMatrix = videoMatrix;
	}

	public VideoMonitor getVideoMonitor() {
		return videoMonitor;
	}

	public void setVideoMonitor(VideoMonitor videoMonitor) {
		this.videoMonitor = videoMonitor;
	}

	public Vidicon getVidicon() {
		return vidicon;
	}

	public void setVidicon(Vidicon vidicon) {
		this.vidicon = vidicon;
	}

	public Yuntai getYuntai() {
		return yuntai;
	}

	public void setYuntai(Yuntai yuntai) {
		this.yuntai = yuntai;
	}

	public BuildingLockEquipmentDao getBuildingLockEquipmentDao() {
		return buildingLockEquipmentDao;
	}

	public void setBuildingLockEquipmentDao(
			BuildingLockEquipmentDao buildingLockEquipmentDao) {
		this.buildingLockEquipmentDao = buildingLockEquipmentDao;
	}

	public BuildingTalkEquipmentDao getBuildingTalkEquipmentDao() {
		return buildingTalkEquipmentDao;
	}

	public void setBuildingTalkEquipmentDao(
			BuildingTalkEquipmentDao buildingTalkEquipmentDao) {
		this.buildingTalkEquipmentDao = buildingTalkEquipmentDao;
	}

	public ControlDiskVideoDao getControlDiskVideoDao() {
		return controlDiskVideoDao;
	}

	public void setControlDiskVideoDao(ControlDiskVideoDao controlDiskVideoDao) {
		this.controlDiskVideoDao = controlDiskVideoDao;
	}

	public VideoMatrixDao getVideoMatrixDao() {
		return videoMatrixDao;
	}

	public void setVideoMatrixDao(VideoMatrixDao videoMatrixDao) {
		this.videoMatrixDao = videoMatrixDao;
	}

	public VideoMonitorDao getVideoMonitorDao() {
		return videoMonitorDao;
	}

	public void setVideoMonitorDao(VideoMonitorDao videoMonitorDao) {
		this.videoMonitorDao = videoMonitorDao;
	}

	public VidiconDao getVidiconDao() {
		return vidiconDao;
	}

	public void setVidiconDao(VidiconDao vidiconDao) {
		this.vidiconDao = vidiconDao;
	}

	public YuntaiDao getYuntaiDao() {
		return yuntaiDao;
	}

	public void setYuntaiDao(YuntaiDao yuntaiDao) {
		this.yuntaiDao = yuntaiDao;
	}

	@Transactional(propagation=Propagation.REQUIRED)
	public String toProduct(){
		buildingLockEquipmentList = buildingLockEquipmentDao.findAll();
		buildingTalkEquipmentList = buildingTalkEquipmentDao.findAll();
		controlDiskVideoList = controlDiskVideoDao.findAll();
		videoMatrixList = videoMatrixDao.findAll();
		videoMonitorList = videoMonitorDao.findAll();
		vidiconList = vidiconDao.findAll();
		yuntaiList = yuntaiDao.findAll();
		return SUCCESS;
	}
	
	public String toProductAdmin(){
		buildingLockEquipmentList = buildingLockEquipmentDao.findAll();
		buildingTalkEquipmentList = buildingTalkEquipmentDao.findAll();
		controlDiskVideoList = controlDiskVideoDao.findAll();
		videoMatrixList = videoMatrixDao.findAll();
		videoMonitorList = videoMonitorDao.findAll();
		vidiconList = vidiconDao.findAll();
		yuntaiList = yuntaiDao.findAll();
		return SUCCESS;
	}
	
	public String toAddYuntai(){
		yuntaiList = yuntaiDao.findAll();
		return SUCCESS;
	}
	
	public String addYuntai(){
		yuntaiDao.saveOrUpdate(yuntai);
		return SUCCESS;
	}
	
	public String toAddVidicon(){
		vidiconList = vidiconDao.findAll();
		return SUCCESS;
	}
	
	public String addVidicon(){
		vidiconDao.saveOrUpdate(vidicon);
		return SUCCESS;
	}
	
	public String toAddVideoMonitor(){
		videoMonitorList = videoMonitorDao.findAll();
		return SUCCESS;
	}
	
	public String addVideoMonitor(){
		videoMonitorDao.saveOrUpdate(videoMonitor);
		return SUCCESS;
	}
	
	public String toAddVideoMatrix(){
		videoMatrixList = videoMatrixDao.findAll();
		return SUCCESS;
	}
	
	public String addVideoMatrix(){
		videoMatrixDao.saveOrUpdate(videoMatrix);
		return SUCCESS;
	}
	
	public String toAddControlDiskVideo(){
		controlDiskVideoList = controlDiskVideoDao.findAll();
		return SUCCESS;
	}
	
	public String addControlDiskVideo(){
		controlDiskVideoDao.saveOrUpdate(controlDiskVideo);
		return SUCCESS;
	}
	
	public String toAddBuildingTalkEquipment(){
		buildingTalkEquipmentList = buildingTalkEquipmentDao.findAll();
		return SUCCESS;
	}
	
	public String addBuildingTalkEquipment(){
		buildingTalkEquipmentDao.saveOrUpdate(buildingTalkEquipment);
		return SUCCESS;
	}
	
	public String toAddBuildingLockEquipment(){
		buildingLockEquipmentList = buildingLockEquipmentDao.findAll();
		return SUCCESS;
	}
	
	public String addBuildingLockEquipment(){
		buildingLockEquipmentDao.saveOrUpdate(buildingLockEquipment);
		return SUCCESS;
	}
	
	public String updateBuildingLockEquipment(){
		buildingLockEquipment = buildingLockEquipmentDao.findById(buildingLockEquipment.getId());
		id = buildingLockEquipment.getId();
		return SUCCESS;
	}
	
	public String deleteBuildingLockEquipment(){
		buildingLockEquipmentDao.delete(buildingLockEquipmentDao.findById(buildingLockEquipment.getId()));
		return SUCCESS;
	}
	
	public String updateBuildingTalkEquipment(){
		buildingTalkEquipment = buildingTalkEquipmentDao.findById(buildingTalkEquipment.getId());
		id = buildingTalkEquipment.getId();
		return SUCCESS;
	}
	
	public String deleteBuildingTalkEquipment(){
		buildingTalkEquipmentDao.delete(buildingTalkEquipmentDao.findById(buildingTalkEquipment.getId()));
		return SUCCESS;
	}
	
	public String updateControlDiskVideo(){
		controlDiskVideo = controlDiskVideoDao.findById(controlDiskVideo.getId());
		id = controlDiskVideo.getId();
		return SUCCESS;
	}
	
	public String deleteControlDiskVideo(){
		controlDiskVideoDao.delete(controlDiskVideoDao.findById(controlDiskVideo.getId()));
		return SUCCESS;
	}
	
	public String updateVideoMatrix(){
		videoMatrix = videoMatrixDao.findById(videoMatrix.getId());
		id = videoMatrix.getId();
		return SUCCESS;
	}
	
	public String deleteVideoMatrix(){
		videoMatrixDao.delete(videoMatrixDao.findById(videoMatrix.getId()));
		return SUCCESS;
	}
	
	public String updateVideoMonitor(){
		videoMonitor = videoMonitorDao.findById(videoMonitor.getId());
		id = videoMonitor.getId();
		return SUCCESS;
	}
	
	public String deleteVideoMonitor(){
		videoMonitorDao.delete(videoMonitorDao.findById(videoMonitor.getId()));
		return SUCCESS;
	}
	
	public String updateVidicon(){
		vidicon = vidiconDao.findById(vidicon.getId());
		id = vidicon.getId();
		return SUCCESS;
	}
	
	public String deleteVidicon(){
		vidiconDao.delete(vidiconDao.findById(vidicon.getId()));
		return SUCCESS;
	}
	
	public String updateYuntai(){
		yuntai = yuntaiDao.findById(yuntai.getId());
		id = yuntai.getId();
		return SUCCESS;
	}
	
	public String deleteYuntai(){
		yuntaiDao.delete(yuntaiDao.findById(yuntai.getId()));
		return SUCCESS;
	}
}
